<title>首页推荐</title>

<div class="layui-card layadmin-header">
<div class="layui-breadcrumb" lay-filter="breadcrumb">
    <a lay-href="">控制台</a>
    <a><cite>问答管理</cite></a>
    <a><cite>首页推荐</cite></a>
</div>
</div>

<div class="layui-fluid">
  <div class="layui-row layui-col-space15">
      <div class="layui-col-md12">
      	<!--s-->
          <div class="layui-card">
             <div class="layui-card-body">
				<div class="layui-tab layui-tab-brief" lay-filter="component-tabs-brief">
		            <ul class="layui-tab-title">
		              <li><a lay-href="wendasns/recommend/index">置顶推荐</a></li>
		              <li class="layui-this"><a lay-href="wendasns/recommend/adpic">首页轮播图</a></li>
		            </ul>
		            <div class="layui-tab-content">
		              <div class="layui-tab-item layui-show">
		              	<blockquote class="layui-elem-quote">轮播图顺序按排序值由大至小排列</blockquote>
					      <div style="padding-bottom: 10px;">
					        <a href="#J_view" class="layui-btn J_popup" title="添加轮播图"><i class="layui-icon layui-icon-add-circle"></i>添加</a>
					        <a href="wendasns/recommend/remove" class="layui-btn J_req" title="确定要删除吗？"><i class="layui-icon layui-icon-delete"></i>删除</a>
					      </div>
                        <table id="J_table_list" lay-filter="J_table_list" url="{:url('wendasns/recommend/edit')}"></table>
		              </div>
		            </div>
		          </div>
              </div>
          </div>
          <!--e-->
          
          
      </div>
  </div>
</div>
<script type="text/html" id="J_table_content">
    {{# if(d.url){ }}<a href="{{d.url}}" target="_blank"><img src="{{d.src}}"/></a>{{# }else{ }}<img src="{{d.src}}"/>{{# } }}<a class="J_photos" style="float: right;" href="{{d.src}}" title="看大图"><i class="layui-icon layui-icon-search"></i></a>
</script>

<script type="text/html" id="J_table_tool">
    <a href="wendasns/recommend/remove" class="layui-btn layui-btn-danger layui-btn-xs" lay-event="req" title="确定要删除吗？"><i class="layui-icon layui-icon-delete"></i>删除</a>
</script>
  
<script>
;!function(){
    var $ = layui.$
  ,form = layui.form
  ,upload = layui.upload
  ,table =layui.table;

  form.render();

    table.render({
      elem: '#J_table_list'
      ,height: 'auto'
      ,url: '{:url('wendasns/recommend/image')}'
      ,page: true
      ,limit: 16
      ,cols: [[
      	{type:'checkbox'}
        ,{field:'content',title:'图片',minWidth:150,toolbar:'#J_table_content'}
        ,{field:'src',title:'图片地址',minWidth:150,edit:'text'}
        ,{field:'url',title:'广告地址',minWidth:150,edit:'text'}
        ,{field:'sort',title:'排序',width:80,align:'center',edit:'text'}
        ,{field:'operate',title:'操作',width:100,align:'center',toolbar: '#J_table_tool'}
      ]]
      ,text: {
        none: '无任何轮播图！'
      }
    });
    
	$(document).on('click','.J_photos',function(event){
		event.preventDefault();
		layer.photos({
	    	photos: {data:[{
		      "alt": "",
		      "pid": 1,
		      "src": $(this).prop('href'),
		      "thumb": ""
	    	}]}
	    });
	});
	
}();

function imgup(){
	layui.upload.render({
      elem: '#J_imgup'
      ,url: '{:url('wendasns/recommend/upload')}'
      ,done: function(res){
      	layer.msg(res.msg);
        layui.$('#advert_content').val(res.data.src);
        layui.$('#adimage').attr('src', res.data.src);
      }
      ,error: function(){
        layer.msg('上传失败');
      }
    });  
}
</script>
<script type="text/html" id="J_view" lay-done="imgup()">

    <form class="layui-form" action="{:url('wendasns/recommend/add')}" method="post">
      
      <div class="layui-form-item" id="J_content_item">
        <label class="layui-form-label">图片</label>
        <div class="layui-input-inline" style="width: 300px;">
            <input id="advert_content" name="pic" placeholder="请输入图片地址" value="" lay-verify="required" autocomplete="off" class="layui-input">
        </div>
      </div>

      <div class="layui-form-item" id="J_img_item">
        <label class="layui-form-label"></label>
        <div class="layui-input-inline">
          <img src="" id="adimage" width="100%" height="50%" alt="图片"/>
        </div>
      </div>

      <div class="layui-form-item">
        <div class="layui-input-block">
        <a id="J_imgup" href="javascript:;" class="layui-btn layui-btn-primary"><i class="layui-icon layui-icon-upload-drag"></i>上传图片</a>
        <p>图片规格353px*280px，支持格式'jpg','jpeg','gif','png'</p>
        </div>
      </div>
      
      <div class="layui-form-item">
        <label class="layui-form-label">链接</label>
        <div class="layui-input-inline" style="width: 300px;">
          <input type="text" name="url" value="" placeholder="请输入链接，可填写" autocomplete="off" class="layui-input">
        </div>
      </div>
      
        <div class="layui-form-item">
          <div class="layui-input-block">
            <button type="button" class="layui-btn" lay-submit lay-filter="J_ajax_submit_btn" >提交</button>
          </div>
        </div>
    </form>
</script>